import http from "./http";

//登录
async function login(from) {
  try {
    const response = await http({
      method: 'post',
      url: '/login',
      data:from
    });
    return response.data;
  } catch (error) {
    console.log(error);
  }
}

//注册
async function register(from) {
  try {
    const response = await http({
      method: 'post',
      url: '/register',
      data: from
    });
    return response.data;
  } catch (error) {
    console.log(error);
  }
}

//获取验证码
async function getVerifyCode(enroll,codeType) {
  try {
    const response = await http({
      method: 'get',
      url: '/VerifyCode/',
      params:{
        email:enroll,
        codeType:codeType
      }
    });
    return response.data;
  } catch (error) {
    console.log(error);
  }
}

//修改密码
async function updatePassword(from) {
  try {
    const response = await http({
      method: 'post',
      url: '/updatePassword',
      data: from
    });
    return response.data;
  } catch (error) {
    console.log(error);
  }
}

export default {login,register,getVerifyCode,updatePassword}
